#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main() {
	string s;
	int cnt = 0;
	cin >> s;
	for (auto ii : s) {
		if (ii == 'Y')
			cnt++;
		else if (cnt)
			cnt--;
	}
	cout << cnt;
	return 0;
}
